package com.zyf.system.until;

/**
 * @author 张云帆
 * 2025/3/25 15:38
 */
import com.zyf.system.annotation.RoleType;
import com.zyf.system.constant.Role;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class RoleValidator implements ConstraintValidator<RoleType, String> {
    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        // 自定义验证逻辑
        if (value == null) {
            return false;
        }
        Role[] roles = Role.values();
        for (Role role : roles) {
            if (role.getHandleType().equals(value)) {
                return true;
            }
        }
        // 示例：验证字符串是否为特定格式
        return false;
    }
}
